package com.summer.framework.admin.mq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

/**
 * @auther: 杨杰
 * @date: 2019/2/22 11:09
 * @description: 如果消息没有到exchange, 则confirm回调, ack=false
 * 如果消息到达exchange,则confirm回调,ack=true
 */
@Slf4j
public class MsgSendConfirmCallBack implements RabbitTemplate.ConfirmCallback {
    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        if (ack) {
            log.info("消息确认成功");
        } else {
            //处理丢失的消息
            log.info("消息确认失败," + cause);
        }
    }
}
